home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 February: Tool Chest / Dev.CD Feb 94.toast / New System Software Extensions / ColorSync™ 1.0.3 / Interfaces / CIncludes / CMApplication.h next >
Encoding:
C/C++ Source or Header  |  1993-07-19  |  8.2 KB  |  357 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        CMApplication.h
  3.  
  4.     Contains:    Header for Color Matching aware applications
  5.  
  6.     Written by:    Konstantin Othmer
  7.  
  8.     Copyright:    © 1992-93 by Apple Computer, Inc., all rights reserved.
  9.  
  10.  
  11. */
  12.  
  13.  
  14. #ifndef __CMAPPLICATION__
  15. #define __CMAPPLICATION__
  16.  
  17. #ifndef __TYPES__
  18. #include <Types.h>
  19. #endif
  20.  
  21. #ifndef __QUICKDRAW__
  22. #include <QuickDraw.h>
  23. #endif
  24.  
  25. #ifndef __PRINTING__
  26. #include <Printing.h>
  27. #endif
  28.  
  29.  
  30. #define    gestaltColorMatchingVersion    'cmtc'
  31.  
  32. #define    CMTrap                0xABEE
  33.  
  34. /*
  35. ** PicComments
  36. */
  37. #define CMBeginProfile        220
  38. #define    CMEndProfile        221
  39. #define    CMEnableMatching    222
  40. #define    CMDisableMatching    223
  41.  
  42. /* Defines for fieldMask in profile search record */
  43. #define kMatchCMMType                0x00000001
  44. #define kMatchApplProfileVersion    0x00000002
  45. #define kMatchDataType                0x00000004
  46. #define kMatchDeviceType            0x00000008
  47. #define kMatchDeviceManufacturer    0x00000010
  48. #define kMatchDeviceModel            0x00000020
  49. #define kMatchDeviceAttributes        0x00000040
  50. #define kMatchFlags                    0x00000080
  51. #define kMatchOptions                0x00000100
  52. #define kMatchWhite                    0x00000200
  53. #define kMatchBlack                    0x00000400
  54.  
  55.  
  56. /* Profile Header version */
  57. #define    kCMApplProfileVersion        0x0100
  58.  
  59. /* Data types */
  60. enum {
  61.     rgbData                = 'RGB ',
  62.     cmykData            = 'CMYK',
  63.     grayData            = 'GRAY',
  64.     xyzData                = 'XYZ '
  65. };
  66.  
  67. /* Device types */
  68. enum {
  69.     monitorDevice        = 'mntr',
  70.     scannerDevice        = 'scnr',
  71.     printerDevice        = 'prtr',
  72.     qdSystemDevice        = 'sys ',
  73.     qdGDevice            = 'gdev'
  74. };
  75.  
  76. /* Profile flags */
  77. enum {
  78.     CMNativeMatchingPreferred     = 0x00000001,        /* Default to native not preferred */
  79.     CMTurnOffCache                = 0x00000002        /* Default to turn on CMM cache */
  80. };
  81.  
  82. typedef long CMMatchFlag;
  83.  
  84. /* Profile options */
  85. enum {
  86.      CMPerceptualMatch        = 0x0000,                /* Default. For photographic images */
  87.      CMColorimetricMatch    = 0x0001,                /* Exact matching when possible */
  88.      CMSaturationMatch        = 0x0002                /* For solid colors */
  89. };
  90.  
  91. typedef long CMMatchOption;
  92.  
  93.  
  94. typedef long CMMatchRef;
  95.  
  96. typedef long CWorld;
  97.  
  98.  
  99. /* ColorSync result codes */
  100. enum {
  101.     CMNoError                = 0,
  102.     CMProfileError            = -170,
  103.     CMMethodError            = -171,
  104.     CMMemFullError            = -172,
  105.     CMUnimplementedError    = -173,
  106.     CMParamError            = -174,
  107.     CMMethodNotFound        = -175,                    /* CMM not present */
  108.     CMProfileNotFound        = -176,                    /* Responder error */
  109.     CMProfilesIdentical        = -177,                    /* Profiles the same */
  110.     CMCantConcatenateError    = -178,                    /* Profile can't be concatenated */
  111.     CMCantXYZ                = -179,                    /* CMM cant handle XYZ space */
  112.     CMCantDeleteProfile        = -180,                    /* Responder error */
  113.     CMUnsupportedDataType    = -181,                    /* Responder error */
  114.     CMNoCurrentProfile        = -182                    /* Responder error */
  115. };
  116.  
  117. typedef long CMError;
  118.  
  119.  
  120. /*
  121. ** Types
  122. */
  123.  
  124. struct XYZColor {
  125.     unsigned short        X;                            /* 1.15 bit unsigned fixed numbers */
  126.     unsigned short        Y;
  127.     unsigned short        Z;
  128. };
  129.  
  130. typedef struct XYZColor        XYZColor;
  131.  
  132.  
  133. struct CMYKColor {
  134.     unsigned short        cyan;
  135.     unsigned short        magenta;
  136.     unsigned short        yellow;
  137.     unsigned short        black;
  138. };
  139.  
  140. typedef struct CMYKColor    CMYKColor;
  141.  
  142.  
  143. union CMColor {
  144.     RGBColor        rgb;
  145.     XYZColor        xyz;
  146.     CMYKColor        cmyk;
  147. };
  148.  
  149. typedef union CMColor        CMColor, *CMColorList;
  150.  
  151.  
  152. typedef long        *CMGamutResult;                    /* Pointer to bit array */
  153.  
  154.  
  155. struct CMHeader {
  156.     unsigned long        size;                        /* This is the total size of the Profile including custom data */
  157.     OSType                CMMType;                    /* Corresponding CMM */
  158.     unsigned long        applProfileVersion;            /* Version of CMProfile format */
  159.     OSType                dataType;                    /* rgbData, etc. */
  160.     OSType                deviceType;                    /* monitorDevice, etc. */
  161.     OSType                deviceManufacturer;            /* Registered with DTS */
  162.     unsigned long        deviceModel;                /* Specific to Manufacturer */
  163.     unsigned long        deviceAttributes[2];        /* Attributes like paper, ink, etc. */
  164.     unsigned long        profileNameOffset;            /* Offset to profile name from top of data */
  165.     unsigned long        customDataOffset;            /* Offset to custom data from top of data */
  166.     CMMatchFlag            flags;
  167.     CMMatchOption        options;
  168.     XYZColor            white;
  169.     XYZColor            black;
  170. };
  171.  
  172. typedef struct CMHeader        CMHeader;
  173.  
  174.  
  175. struct CMProfileSearchRecord {
  176.     CMHeader        header;
  177.     unsigned long    fieldMask;
  178.     unsigned long    reserved[2];
  179. };
  180.  
  181. typedef struct CMProfileSearchRecord    CMProfileSearchRecord, **CMProfileSearchRecordHandle;
  182.  
  183.  
  184. struct CMProfileChromaticities {
  185.     XYZColor        red;
  186.     XYZColor        green;
  187.     XYZColor        blue;
  188.     XYZColor        cyan;
  189.     XYZColor        magenta;
  190.     XYZColor        yellow;
  191. };
  192.  
  193. typedef struct CMProfileChromaticities    CMProfileChromaticities;
  194.  
  195.  
  196. typedef unsigned short CMResponseData;
  197.  
  198.  
  199. struct IString {
  200.     ScriptCode        theScript;
  201.     Str63            theString;
  202. };
  203.  
  204. typedef struct IString    IString, *IStringPtr, **IStringHandle;
  205.  
  206.  
  207. enum {
  208.     grayResponse = 0,
  209.     redResponse,
  210.     greenResponse,
  211.     blueResponse,
  212.     cyanResponse,
  213.     magentaResponse,
  214.     yellowResponse,
  215.     ucrResponse,
  216.     bgResponse,
  217.     onePlusLastResponse
  218. };
  219.  
  220. typedef long responseColor;
  221.  
  222. struct CMProfileResponse {
  223.     unsigned short         counts[onePlusLastResponse];
  224.     CMResponseData        data[1];                        /* Variable size */
  225. };
  226.  
  227. typedef struct CMProfileResponse    CMProfileResponse;
  228.  
  229.  
  230. struct CMProfile {
  231.     CMHeader                header;
  232.     CMProfileChromaticities profile;
  233.     CMProfileResponse        response;                    /* Variable size */
  234.     IString                    profileName;                /* Variable size */
  235.     char                    customData[1];                /* Optional variable length custom CMM data */
  236. };
  237.  
  238. typedef struct CMProfile    CMProfile, *CMProfilePtr, **CMProfileHandle;
  239.  
  240.  
  241. typedef pascal Boolean (*PixMapCallBackProcPtr)( long progress, long refCon );
  242.  
  243. /*
  244. ** Printing Stuff that will be moved later
  245. */
  246.  
  247. enum {
  248.     enableColorMatchingOp    =12,
  249.     registerProfileOp        =13
  250.     };
  251.  
  252. /* PrGeneral parameter blocks */
  253.  
  254. struct TEnableColorMatchingBlk
  255. {
  256.     short    iOpCode;
  257.     short    iError;
  258.     long    lReserved;
  259.     THPrint    hPrint;
  260.     Boolean    fEnableIt;
  261. };
  262.  
  263. typedef struct TEnableColorMatchingBlk TEnableColorMatchingBlk;
  264.  
  265.  
  266. struct TRegisterProfileBlk
  267. {
  268.     short    iOpCode;
  269.     short    iError;
  270.     long    lReserved;
  271.     THPrint    hPrint;
  272.     Boolean    fRegisterIt;
  273. };
  274.  
  275. typedef struct TRegisterProfileBlk TRegisterProfileBlk;
  276.  
  277.  
  278. /*
  279. ** High Level Calls
  280. */
  281.  
  282. #define CMCall( selector, argsize ) {0x203c,argsize,selector,CMTrap}
  283.  
  284. pascal CMError BeginMatching( CMProfileHandle src, CMProfileHandle dst,  CMMatchRef *myRef )
  285.     = CMCall( 10, 0x000C );
  286.  
  287. pascal void EndMatching( CMMatchRef myRef )
  288.     = CMCall( 11, 0x0004 );
  289.  
  290. pascal CMError GetProfile( long deviceType, long refNum, CMProfileHandle aProfile, CMProfileHandle *returnedProfile )
  291.     = CMCall( 5, 0x0010 );
  292.  
  293. pascal CMError SetProfile( long deviceType, long refNum, CMProfileHandle newProfile )
  294.     = CMCall( 6, 0x000c );
  295.  
  296. pascal CMError SetProfileDescription( long deviceType, long refNum, long deviceData, CMProfileHandle hProfile )
  297.     = CMCall( 16, 0x0010 );
  298.  
  299. pascal CMError GetColorSyncFolderSpec(short vRefNum, Boolean createFolder, short *foundVRefNum, long *foundDirID)
  300.     = CMCall( 17, 0x000c );
  301.  
  302. pascal CMError GetIndexedProfile( long deviceType, long refNum, CMProfileSearchRecordHandle search,
  303.         CMProfileHandle *returnProfile, long *index )
  304.     = CMCall( 18, 0x0014 );
  305.  
  306. pascal CMError DeleteDeviceProfile( long deviceType, long refNum, CMProfileHandle deleteMe )
  307.     = CMCall( 19, 0x000C );
  308.  
  309. /*
  310. ** Data interchange routines
  311. */
  312. pascal CMError UseProfile( CMProfileHandle profile )
  313.     = CMCall( 8, 0x0004 );
  314.  
  315. pascal void DrawMatchedPicture( PicHandle myPicture, CMProfileHandle dst, Rect *myRect )
  316.     = CMCall( 9, 0x000C );
  317.  
  318. pascal void EnableMatching( Boolean enableIt )
  319.     = CMCall( 13, 0x0002 );
  320.  
  321. /*
  322. ** Profile concatenation
  323. */
  324. pascal CMError ConcatenateProfiles( CMProfileHandle thru, CMProfileHandle dst, CMProfileHandle *newDst )
  325.     = CMCall( 12, 0x000C );
  326.  
  327. /*
  328. ** Profile manipulation routines
  329. */
  330. pascal    void    GetProfileName( CMProfileHandle myProfile, IString *IStringResult )
  331.     = CMCall( 14, 0x0008 );
  332.  
  333. pascal    long    GetProfileAdditionalDataOffset(    CMProfileHandle myProfile )
  334.     = CMCall( 15, 0x0004 );
  335.  
  336. /*
  337. ** Low level color calculation routines
  338. */
  339. pascal CMError CWNewColorWorld( CWorld *myCWorld, CMProfileHandle src, CMProfileHandle dst )
  340.     = CMCall( 0, 0x000C );
  341.  
  342. pascal void CWDisposeColorWorld( CWorld myCWorld )
  343.     = CMCall( 1, 0x0004 );
  344.  
  345. pascal CMError    CWMatchColors( CWorld myCWorld, CMColorList myColors, long count )
  346.     = CMCall( 2, 0x000c );
  347.  
  348. pascal CMError CWCheckColors( CWorld myCWorld, CMColorList myColors, long count, CMGamutResult result )
  349.     = CMCall( 3, 0x0010 );
  350.  
  351. pascal CMError CWMatchPixMap( CWorld myCWorld, PixMap *myPixMap, PixMapCallBackProcPtr progressProc, long refCon )
  352.     = CMCall( 4, 0x0010 );
  353.  
  354. pascal CMError CWCheckPixMap( CWorld myCWorld, PixMap *myPixMap, PixMapCallBackProcPtr progressProc, long refCon, BitMap *resultBitMap )
  355.     = CMCall( 7, 0x0014 );
  356.  
  357. #endif